//
//  JwFile.h
//  JwPack
//
//  Created by 陈警卫 on 2024-08-01.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@interface JwFile : NSObject

/// 判断文件存在
+ (BOOL)fileExist:(NSString *)path;

/// 创建文件夹
+ (BOOL)createFolder:(NSString *)path;

/// 删除文件夹
+ (BOOL)removeFolder:(NSString *)path;

/// 创建文件
+ (BOOL)createFile:(NSString *)path;

/// 删除文件
+ (BOOL)removeFile:(NSString *)path;

/// 读取文件
+ (NSData *)readFile:(NSString *)path;

@end

@interface JwFile (Write)

/// 写入文件
+ (BOOL)writeFile:(NSString *)path string:(NSString *)value;

/// 写入文件
+ (BOOL)writeFile:(NSString *)path array:(NSArray *)value;

/// 写入文件
+ (BOOL)writeFile:(NSString *)path dictionary:(NSDictionary *)value;

/// 写入文件
+ (BOOL)writeFile:(NSString *)path image:(UIImage *)value;

/// 写入文件
+ (BOOL)writeFile:(NSString *)path data:(NSData *)value;

@end

@interface JwFile (Paths)

/// Home path
+ (NSString *)homePath;

/// Document path
+ (NSString *)documentsPath;

/// Library path
+ (NSString *)libraryPath;

/// Preferences path
+ (NSString *)preferencesPath;

/// Caches path
+ (NSString *)cachesPath;

/// tmp path
+ (NSString *)tmpPath;

@end

@interface JwFileHandle : NSObject

/// 数据写入文件
+ (BOOL)write:(NSString *)path value:(NSString *)value;

/// 数据写入文件
+ (BOOL)write:(NSString *)path data:(NSData *)data;

@end

NS_ASSUME_NONNULL_END
